VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "clsINI"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Private tINIFile As String          'The INI File Name

Public Property Get INIFile() As String
    INIFile = tINIFile
End Property

Public Property Let INIFile(T As String)
    tINIFile = T
End Property

'Write the setting to the file
Public Function WriteIni(ByVal Section As String, ByVal Key As String, ByVal Value As String, ByVal Filename As String) As Boolean
    On Error Resume Next
    Dim X As Long, Buff As String * 128, I As Integer
    Buff = Value + Chr(0)
    X = WritePrivateProfileString(Section, Key, Buff, Filename)
    WriteIni = X
End Function

'Retrieve a string
Public Function ReadIni(ByVal Section As String, ByVal Key As String, ByVal Filename As String) As String
    On Error Resume Next
    Dim X As Long, Buff As String * 128, I As Integer
    X = GetPrivateProfileString(Section, Key, "", Buff, 128, Filename)
    I = InStr(Buff, Chr(0))
    ReadIni = Trim(Left(Buff, I - 1))
End Function
